#include "udp.h"
#include <arpa/inet.h>
#include <string.h>

UDPMessage::UDPMessage()
{
}

UDPMessage::~UDPMessage()
{
}

void UDPMessage::setSource( const IPv6Address &sourceAddress )
{
	sourceAddress_ = sourceAddress;
}

void UDPMessage::setDestination( const IPv6Address &destinationAddress )
{
	destinationAddress_ = destinationAddress;
}

void UDPMessage::setData( const PacketBuffer &packetData )
{
	packet_ = packetData;
}

void UDPMessage::setData( const uint8_t *buffer, const int &size )
{
	PacketBuffer buff( buffer, size );
	setData( buff );
}

IPv6Address UDPMessage::source( ) const 
{
	return sourceAddress_; 
}

IPv6Address UDPMessage::destination( ) const 
{
	return destinationAddress_; 
}


/*
std::string UDPMessage::source() const
{
	char source[INET6_ADDRSTRLEN];
	memset( source, 0, INET6_ADDRSTRLEN ); //NULL OUT THE STRING
	inet_ntop( AF_INET6, &(sourceAddress_.sin6_addr), source, sizeof( sourceAddress_ ));
	return std::string( source );
}

std::string UDPMessage::destination() const
{
	char destination[INET6_ADDRSTRLEN];
	memset( destination, 0, INET6_ADDRSTRLEN ); //NULL OUT THE STRING
	inet_ntop( AF_INET6, &(destinationAddress_.sin6_addr), destination, sizeof( destinationAddress_ ));
	return std::string( destination );
}
*/

PacketBuffer UDPMessage::data() const
{
	return packet_;
}


